#include <QtGui/QApplication>
#include "mainwindow.h"
#include "limage.h"
#include <QImage>
#include <QString>
#include <iostream>
#include <string>
using namespace std;


int main(int argc, char *argv[])
{   bool isGray;
    QApplication a(argc, argv);
//    MainWindow w;
  //  w.show();

    QImage output2;
   cout<<"HI"<<endl;

   QString inputFileName("space-01.jpg");
   LImage space(inputFileName);





   LImage grayscaleSpace= space.convertToGrayScale();
   QString outputFileName("GrayscaleSpace.jpg");
   grayscaleSpace.saveImage(outputFileName);
   cout<<"The FirstIsDone"<<endl;
   QString negativeFileName("NegativeSpaceFile.jpg");
   QString equalizedHistogramFileName("equal.jpg");
   LImage equalizedHisto;
   LImage negativeGrayscaleSpace= grayscaleSpace.convertToNegative();
   negativeGrayscaleSpace.saveImage(negativeFileName);
   negativeGrayscaleSpace.historgram->calcHistogram();
   // equalizedHisto= negativeGrayscaleSpace.histogramEqulization();
    //equalizedHisto.saveImage(equalizedHistogramFileName);
   QString lenaFileName="lena.jpg";

   LImage histogramImage(lenaFileName);
   //histogramImage.historgram.calcHistogram();
  // histogramImage.historgram.calcCDF();
   cout<<"_____________________________-----------------------------------------"<<endl;
   equalizedHisto=histogramImage.histogramEqulization();
   equalizedHisto.saveImage(equalizedHistogramFileName);
   cout<<"_____________________________-----------------------------------------"<<endl;
    QString mergedGrayscaleFileName= "MergedGrayScale.jpg"    ;
    LImage mergedGrayscale= grayscaleSpace.mergeImage(0.2,negativeGrayscaleSpace,0.8);
    mergedGrayscale.saveImage(mergedGrayscaleFileName);

      QString firstColoredImageFileName= "gre.jpg";
      QString secondColoredImageFileName="gre2.jpg";

      QString colorMergingResultFileName= "ColorMergingResult3.jpg";

      LImage firstColorImage(firstColoredImageFileName);
      LImage secondColoredImage(secondColoredImageFileName);
      LImage tempImage= secondColoredImage.convertToGrayScale();

      LImage colorMergingResult=firstColorImage.mergeImage(0.5,tempImage,0.5);
      colorMergingResult.saveImage(colorMergingResultFileName);
      QString equalizedColorFile("equalizedColorLena.jpg");
      QString inputEqalizationFileName("parrots.jpg");
      LImage inputEqualization(inputEqalizationFileName);
      LImage equalizedColorImage=inputEqualization.histogramEqulization();

      equalizedColorImage.saveImage(equalizedColorFile);
      QString  outputColorNegativeFileName("ColorNegativeOutput.jpg");
      LImage outputColorNegativeImage= inputEqualization.convertToColorNegative();
      QString equalizedColorNegativesFileName("EqualizedColorNegative.jpg");
      //LImage equalizedColorNegative= outputColorNegativeImage.histogramEqulization();
      outputColorNegativeImage.saveImage(outputColorNegativeFileName);
     
     
     //equalizedColorNegative.saveImage(equalizedColorNegativesFileName);

cout<<"THEEY";
QString PGMInputFileName("Lena.pgm");
const char* ptr=(const char*)4;

LImage PGMInputImage(PGMInputFileName,3);
QString PgmResultFileName("PGM.pgm");
LImage PgmResultImage= PGMInputImage.convertToNegative();
PgmResultImage.saveImage(PgmResultFileName);
QString lenaFile("lena_color.jpg");
LImage HSVEqualizedLena(lenaFile);

LImage testImage= HSVEqualizedLena.HSIHistogramEqualization();
LImage testImageRGb =HSVEqualizedLena.histogramEqulization();
QString testImageRGBFileName("testImageRGB.jpg");
testImageRGb.saveImage(testImageRGBFileName);
QString HSVEqualizedHistogram("HSVEqualizedHistogram3.jpg");
testImage.saveImage(HSVEqualizedHistogram);
QString grayParrotsFileName("GrayParrotsImage.jpg");
LImage grayParrotsImage= inputEqualization.convertToGrayScale();
grayParrotsImage.saveImage(grayParrotsFileName);
QString grayHistogramStretchingFileName= "wom.jpg";
LImage grayHistogramStretchingImage(grayHistogramStretchingFileName);
LImage grayHistogramStretchingoutput= grayHistogramStretchingImage.grayHistogramStretching();
QString grayHistogramStretchingOutputFileName="grayHistogramStretchingnOutput.jpg";
grayHistogramStretchingoutput.saveImage(grayHistogramStretchingOutputFileName);
QString inputColorhistogramStretchingfileName("lena_color.jpg");
LImage inputColorhistogramStretchingImage(inputColorhistogramStretchingfileName);
LImage outputColorStretchingImage= inputColorhistogramStretchingImage.colorHSIHistogramStretching();
QString colorStrechingFileName("ColorStretchingImage.jpg");
outputColorStretchingImage.saveImage(colorStrechingFileName);

//return a.exec();
  return 0;
}
